﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Principal;
using System.Text;

namespace CommerceOne.Domains.Authentication
{
    public class CommerceOnePrincipal : IPrincipal
    {

        public CommerceOnePrincipal(CommerceOneIdentity identity)
        {
            this.Identity = identity;
        }
        public IIdentity Identity{ get; private set; }

        /// <summary>
        /// Determines whether the current principal belongs to the specified role.
        /// </summary>
        /// <param name="role">The name of the role for which to check membership.</param>
        /// <returns>
        /// true if the current principal is a member of the specified role; otherwise, false.
        /// </returns>
        public bool IsInRole(string role)
        {
            return ((CommerceOneIdentity) this.Identity).Role.Equals(role, StringComparison.OrdinalIgnoreCase);
        }
    }
}
